package com.xp.code.daoImpl;

import java.sql.CallableStatement;
import java.sql.Connection;

import oracle.jdbc.driver.OracleTypes;

import org.hibernate.Session;
import org.springframework.stereotype.Repository;

import com.xp.code.dao.IPostInfoDao;
import com.xp.code.jpa.DefaultJPADAO;
import com.xp.code.util.CommonUtils;
import com.xp.code.vo.DeptInfoVO;
import com.xp.code.vo.PostInfoVO;
/**
 * 
 * @author HAHA
 *
 */
@Repository("postInfoDao")
public class PostInfoDao extends DefaultJPADAO implements IPostInfoDao {

	public PostInfoDao() {
		
	}

	public PostInfoVO addPostInfos(PostInfoVO postInfoVO) throws Exception {
		PostInfoVO vo=null;
		CallableStatement cs = null;
		int FLAG = 0;
		String MSG = "添加成功";
		try {
			Session session = (Session) this.getEntityManager().getDelegate();
			Connection con = session.connection();
			cs = con.prepareCall("{CALL PACKAGEXPSYS_AUTH.AddPostInfo(?,?,?,?,?,?,?)}");
			cs.setString(1, CommonUtils.getUUID());
			cs.setString(2, postInfoVO.getVarname());
			cs.setString(3, postInfoVO.getVarcode());
			cs.setString(4, postInfoVO.getParentid());
			cs.setString(5, postInfoVO.getRemark());
			cs.registerOutParameter(6, OracleTypes.INTEGER);
			cs.registerOutParameter(7, OracleTypes.VARCHAR);
			cs.executeUpdate();
			FLAG = cs.getInt(6);
			MSG = cs.getString(7);
			vo=new PostInfoVO(FLAG,MSG);
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			if (cs != null) {
				cs.close();
			}
		}
		return vo;
	}
	
}
